﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text;

namespace MobileManager.UserControl
{
    public partial class SMMenu : System.Web.UI.UserControl
    {
        private MM.Model.T_Users userModel;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["CurUser"] == null)
            {
                Response.Redirect("../Login.aspx");
                return;
            }
            else
            {
                userModel = (MM.Model.T_Users)Session["CurUser"];
            }
            if (!IsPostBack)
            {
                StringBuilder sbHTML = new StringBuilder(500);
                string strRequst = Request.Url.ToString().ToLower();
                sbHTML.Append("<table id=\"TBmenu\">");
                sbHTML.Append(string.Format("<tr><td><a href=\"UserManager.aspx\" class=\"{0}\" target=\"_self\">用户管理</a></td></tr>", GetClassName(strRequst, "UserManager")));
                if (userModel.RoleID.Equals("1"))
                    sbHTML.Append(string.Format("<tr><td><a href=\"UserCusManager.aspx\" class=\"{0}\" target=\"_self\">客户管理</a></td></tr>", GetClassName(strRequst, "UserCusManager")));
                sbHTML.Append(string.Format("<tr><td><a href=\"LogsManager.aspx\" class=\"{0}\" target=\"_self\">日志管理</a></td></tr>", GetClassName(strRequst, "LogsManager")));
                sbHTML.Append("</table>");
                divMenu.InnerHtml = sbHTML.ToString();
            }
        }
        private string GetClassName(string strRequst, string strPage)
        {
            if (strRequst.Contains(strPage.ToLower()))
                return "Aselected";
            else return "Anormal";
        }
    }
}